<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        出库记录
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../../../css/bootstrap.css">
    <link rel="stylesheet" href="../../../../lib/layui/css/layui_2.5.7.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .layui-table-page select {
            height: 22px;
        }
    </style>
</head>

<body>
<div>
    <div class="main_box">
        <div class="panel-heading">
            <ul class="nav nav-tabs" id="navTabs">
                <li class=""><a class="receivePane" data-tab=""  href="#" onclick="p_admin_add('详情【物料号：'+ partsNum + '】','iventory_details.html?recordId='+recordId+ '&partsNum='+partsNum,'1200','600')">详情</a></li>
                <li class=""><a class="payPane" data-tab="" href="#" onclick="p_admin_add('详情【物料号：'+ partsNum + '】','iventory_warehousing_record.html?recordId='+recordId+ '&partsNum='+partsNum,'1200','600')">入库记录</a></li>
                <li class="active"><a class="payPane" data-tab="" href="#" onclick="p_admin_add('详情【物料号：'+ partsNum + '】','iventory_delivery_record.html?recordId='+recordId+ '&partsNum='+partsNum,'1200','600')">出库记录</a></li>

            </ul>
        </div>
    </div>

    <form class="layui-form x-center">
        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item">
                <label class="layui-form-label">出库库房</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="name" id="name" placeholder="输入出库库房名称">
                </div>


                <div class="layui-input-inline layui-show-xs-block">
                    <button class="layui-btn" type="button" lay-filter="sreach" data-type="reload"
                            onclick="reload()">
                        <i class="layui-icon">&#xe615;</i></button>
                </div>

            </div>
        </div>
    </form>

    <div class="layui-card-body">

        <table class="layui-table" id="test" lay-filter="test">
        </table>
    </div>
    <br><br><br><br><br><br>

</div>
</body>

<script type="text/html" id="barDemo">

    <a class="layui-btn layui-btn-danger layui-btn-xs" style="background: blue;" lay-event="xiangqing">详情</a>
</script>
<script type="text/javascript" src="../../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../../js/pub.js"></script>
<script type="text/javascript" src="../../../../lib/layui/layui2.5.7.js"></script>
<script type="text/javascript" src="../../../../js/vue.min.js"></script>
<!-- <script src="lib/layui/layui.js" charset="utf-8"></script> -->
<script src="../../../../js/x-layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
    //配置插件目录
    layui.config({
        base: '../../js/'
        , version: '1.0'
    });
</script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer', 'form', 'upload'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element;//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        var form = layui.form;
        okLoading.close($);
    });

    function p_admin_add(title,url,w,h){
        p_admin_show(title,url,w,h);
    }
</script>


<script>
    var recordId = getQueryVariable("recordId");
    var partsNum = getQueryVariable("partsNum");
    console.log(partsNum);


    layui.use('table', function () {
        table = layui.table;
        //方法级渲染
        var t1 = table.render({
            elem: '#test',
            url: $baseUrl + 'kf/parts/getOutWarehouse',
            where: {
                userId: $userId,
                partsId:recordId,
            },
            headers: {
                token: $token
            },
            method: "POST"
            , toolbar: '#toolbarDemo',

            // toolbar: true,
            cols: [
                [
                    {
                        title: '出库日期',
                        fixed: 'left',
                        templet: function (item) {
                            return item.outTime;
                        },
                    },
                    {
                        title: '方式',
                        templet: function (item) {
                            return item.outType == null ? '空' : item.outType;
                        }
                    },
                    {
                        title: '名称',
                        templet: function (item) {
                            return item.clientName == null ? '空' : item.clientName;
                        }
                    },
                    {
                        title: ' 领取人',
                        templet: function (item) {
                            return item.receiverName == null ? '空' : item.receiverName;
                        }
                    },
                    {
                        title: '出库数量',
                        templet: function (item) {
                            return item.outCount;
                        }

                    },
                    {
                        title: '出库库房',
                        templet: function (item) {
                            return item.warehouseName == null ? '空' : item.warehouseName;
                        }

                    },

                    {
                        field: 'status',
                        title: '操作',
                        templet: '#barDemo',
                        fixed: 'right',
                        width: '15%'
                    }]
            ],
            request: {
                pageName: 'page', //页码的参数名称，默认：page
                limitName: 'size',
            },
            response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                ,
                statusCode: 0 //规定成功的状态码，默认：0
                ,
                msgName: 'msg' //规定状态信息的字段名称，默认：msg
                ,
                countName: 'total' //规定数据总数的字段名称，默认：count
                ,
                dataName: 'data.partsOutWarehouseData', //规定数据列表的字段名称，默认：data
            },
            id: 'test',
            page: true,
            height: 'auto',
            even: true,
            done: function (res, curr, count) {
                //是否有权限或权限是否失效
                // authorizeState();
                console.log(res);
            }
        });


        //修改状态
        let form = layui.form;




        //监听工具条
        table.on('tool(test)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            let data = obj.data; //获得当前行数据
            let layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            if (layEvent === 'del') { //删除
                layer.confirm('是否确认删除 ？', {
                    icon: 3,
                    title: '提示'
                }, function (index) {
                    let request = {
                        url: "kf/parts/deleteParts?id=" + data.id,
                        data: {
                            userId: $userId,
                        },
                        method: "GET",
                    };
                    sendRequest(request, (data) => {
                        if (data.code === 0) {
                            layer.msg("删除成功", {
                                icon: 1
                            });
                            t1.reload();
                        } else {
                            layer.msg("删除失败，请稍后再试！", {
                                icon: 5
                            });
                        }
                    });
                    layer.close(index);
                });
            } else if (layEvent === 'view') { //详情
                admin_add('编辑', 'iventory_query_edit.html?recordId=' + data.id)
            }else if(layEvent === 'xiangqing'){
                p_admin_add('详情', '../storageroom/material_information/material_out/material_out.html?recordId=' + data.id ,'1200','600')
            }
        });

    });
    function reload(value) {
        table.reload('test', {
            where: {
                warehouseName: $("#name").val(),

            }
        });
    }

    function admin_add(title, url, w, h) {
        x_admin_show(title, url, w, h);
    }


</script>


</html>
